package com.itheima.flowcontrol.loop;

public class ForForDemo01 {
    public static void main(String[] args) {
        //第一个小作业
//        test1();
        //第二个小作业
//        test2();
        //第三个小作业
//        test3();
//        test4();
        test5();
    }

    public static void test5() {
        //打印99乘法表 使用嵌套循环
        for (int i = 1; i <= 9 ; i++) { //i = 1 j = 1  ; i = 2 j = 1 j = 2
            for (int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + i*j + "\t");

            }
            System.out.println();
        }


    }

    private static void test4() {
        //打印99乘法表
        for (int i = 1; i <= 9; i++) {//行数 i = 1 j = 1
            for (int j = 1; j <= i ; j++) {//列数
                System.out.print(j + "*" + i  + "=" + j * i + " " );
            }
            System.out.println();
        }
    }

    private static void test3() {
        int n = 6;
        for (int i = 0; i < n ; i++) {//外层循环控制行数
            for (int j = 0; j < n - i; j++) {
                System.out.print(" ");//打印空格

            }
            for (int j = 0; j < 2 * i - 1 ; j++) {
                System.out.print("*");//打印星号
            }
            System.out.println();
        }
    }

    private static void test2() {
        for (int i = 0; i < 5; i++) {//代表行数
            for (int j = 0; j < 5 - i; j++) {//代表列数
                System.out.print("*");
            }
            System.out.println();
        }
    }

    private static void test1() {
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}
